// JavaScript Document
setFontsize();
window.addEventListener('resize', function (event) {
	setFontsize();
});
function setFontsize() {
	var winWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
	var clientWidth = winWidth < 320 ? 320 : winWidth > 750 ? 750 : winWidth;
	document.documentElement.style.fontSize = clientWidth / 7.5 + 'px';
}

var pageNum = 1;
function getJumpInfo(page, rows, schoolId, typeId) {
	var data = {
		page:page,
		rows:rows,
		schoolId:schoolId,
		typeId:typeId
	};
	myAjax('post', ARI_API + '/family/ecampus/pageCampusArticle', setListHtml, data);
}

var scrollEvent = function (page, rows, schoolId, typeId) {
	if(!typeId) {
		var info = $('<p class="null-img"></p><span class="text">数据正在创建中...</span>');
		$('#null-box').append(info);
		return;
	}
	getJumpInfo(page, rows, schoolId, typeId);
	function fn() {
		var clientH = document.documentElement.clientHeight || document.body.clientHeight,
			scrollT = document.documentElement.scrollTop || document.body.scrollTop,
			scrollH = document.documentElement.scrollHeight || document.body.scrollHeight,
			data;

		if (clientH + scrollT + 200 >= scrollH) {
			// =>还差100PX就到页面最底部了:此时我们加载更多数据
			$(window).off('scroll', fn);
			page++;
			if (page > pageNum) {
				return;
			}
			// getJumpInfo(page,rows,schoolId,typeId,fn);
			data = {
				page:page,
				rows:rows,
				schoolId:schoolId,
				typeId:typeId
			};
			$.ajax({
				type: 'post', // 提交方式
				url:  ARI_API + '/family/ecampus/pageCampusArticle', // 路径
				dataType: 'json', // 服务器返回数据的类型
				headers:ajaxHeader(),
				data: encrypt(JSON.stringify(data)),
				success: function(result) {
					if (result['status'] == 200) {
						setListHtml(result['content']);
						setTimeout(function () {
							$(window).on('scroll', fn);
						}, 500);
					}
				},
				error: function() {
					//  
				}
			});
		}
	}
	$(window).on('scroll', fn);
};

// 页面跳转至内容页
function jumpPage(id) {
	// console.log(id,'45454545454545');
	location.href = 'about.html?articleId=' + id
}
